<LINK REL=StyleSheet HREF=geral.css TYPE=text/css>
<?

			//Fun�es DOMXML Vers� => 2.4.21

            function getSystems($xml_file) {
               global $sistemas;
               //$objeto  = domxml_open_file($xml_file);
			   //$raiz = $objeto->document_element();
               $objeto = new DOMDocument();
               $objeto->load($xml_file);
			   $filho = $objeto->getelementsbytagname("lin_systems");
			   if ($filho->length > 0) {
                  $temp = $filho->item(0)->getelementsbytagname("system");
                  $j = 0;
                  for($i = 0; $i < $temp->length; $i++) {
                     $method = $temp->item($i)->getelementsbytagname("method");
                     $conteudo = $method->item(0)->nodeValue;
                     if ($conteudo == 'direct') {
                        $sistemas[$j] = $temp->item($i);
                        $j++;
                     }
                  }
                  return $sistemas;
               }
               else return null;
            }

            function getDim($indice) {
               global $sistemas, $dim;
               $dimensao = $sistemas[$indice]->getelementsbytagname("dim");
               $dim = $dimensao->item(0)->nodeValue;
               return $dim;
            }

            function getDesc($indice) {
               global $sistemas, $desc;
               $descricao = $sistemas[$indice]->getelementsbytagname("description");
               $desc = $descricao->item(0)->nodeValue;
               return $desc;
            }

            function getCom($indice) {
               global $sistemas, $com;
               $comentario = $sistemas[$indice]->getelementsbytagname("comments");
               if ($comentario->length > 0) {
                  $com = $comentario->item(0)->nodeValue;
                  return $com;
               }
               else return null;
            }

            function getRef($indice) {
               global $sistemas, $ref;
               $referencia = $sistemas[$indice]->getelementsbytagname("reference");
               if ($referencia->length > 0) {
                  $ref = $referencia->item(0)->nodeValue;
                  return $ref;
               }
               else return null;
            }

            function getMatrix($indice) {
               global $sistemas, $A;
               $linhas = $sistemas[$indice]->getelementsbytagname("row");
     		   for($i = 0; $i < $linhas->length; $i++) {
                  $x = $linhas->item($i)->getelementsbytagname("x");
                  for($j = 0; $j < $x->length; $j++) {
                     $A[$i][$j] = $x->item($j)->nodeValue;
                  }
     		   }
               return $A;
            }


            function createMenu() {
               global $sistemas;
               for($i = 0; $i < sizeof($sistemas); $i++) {
                  echo "<a class=bibliotecaexemplos href=javascript:createLinks($i)><u>";
                  echo XML_EXIBE_SELA_MSG01; echo getDim($i);
                  echo "</u></a><p>";
               }
               return;
            }


?>

<? if (empty($xml_file) && empty($id_bib)) { ?>

        <form name="myform" enctype="multipart/form-data" method="post">

        <script language="javascript" type="text/javascript">
            function goNextPage() {

               document.myform.action = 'index.php?inc=exibe_prob_sela_gauss3_xml.php';
               document.myform.submit();
            }

        </script>

     <p align=left><font face=Arial><? echo XML_EXIBE_MSG01; ?></font>
     <p>
     <?    //oferece a opcao de visualizar exemplos de outro professor
           global $logado, $id_usuario, $tipo_usuario, $status_usuario;
           //if ($logado) {
               echo "<select name=id_bib size=1>";
               ListaBibliotecas();
               echo "</select>";
           //}

     ?>

     <p>
     <input type="hidden" name="document_root" value="<? echo $DOCUMENT_ROOT ?>">
     <input class="button" type="button" value=<? echo XML_EXIBE_MSG03; ?> onClick="goNextPage()"><p>
     </form>

<? } else if ( (!isset($indice)) || ($indice == null) ) { ?>

<title> <? echo XML_TITLE; ?> </title>
<p>
<p class=titulo align="center"><font face="Arial Black"><? echo XML_TITLE_SELA; ?></font></p>
<p class=subtitulo align="center"><font face="Arial Black"><? echo XML_EXIBE_SELA_SUBTITLE_3; ?></font></p>
<p>
<p>

        <form name="myform" enctype="multipart/form-data" method="post">

        <script language="javascript" type="text/javascript">
            function createLinks(value) {
               document.myform.indice.value = value;
               document.myform.action = 'index.php?inc=exibe_prob_sela_gauss3_xml.php';
               document.myform.submit();
            }

        </script>

	  <? //$document_root = 'c:/adaptweb/adaptweb/html/anaweb';
      ?>


        <? if (isset($id_bib)) $xml_file = $DOCUMENT_ROOT."/bibliotecas/".$id_bib; ?>
        <? verificaBib($xml_file); ?>
        <?  if (file_exists($xml_file)) {
                $temp = getSystems($xml_file);
                if (!$temp==null) {
                   echo "<p>";
                   echo "<p align=left><font face=Arial>".XML_EXIBE_MSG04."</font>";
                   echo "<p>";
                   createMenu();
                } else {
                     echo XML_EXIBE_MSG05;
                     echo "<p><input class=button type=button value=".XML_BACK." onClick=history.back()>";
                }
	    } else {
                 echo XML_EXIBE_MSG06;
                 echo "<p><input class=button type=button value=".XML_BACK." onClick=history.back()>";
	    }
 	 ?>

        <input type="hidden" name="id_bib" value="<? echo $id_bib ?>">
        <input type="hidden" name="xml_file" value="<? echo $xml_file ?>">
        <input type="hidden" name="indice">
        <input class="button" type="button" value=<? echo XML_EXIBE_MSG07; ?> onClick="history.back()">
        </form>

<? } else { ?>

<title> <? echo XML_TITLE; ?> </title>
<p>
<p class=titulo align="center"><font face="Arial Black"><? echo XML_TITLE_SELA; ?></font></p>
<p class=subtitulo align="center"><font face="Arial Black"><? echo XML_EXIBE_SELA_SUBTITLE_3; ?></font></p>
<p>
<p>

        <form name="myform" enctype="multipart/form-data" method="post">

        <script language="javascript" type="text/javascript">
            function sendToCalculus() {
               document.myform.Calcular.value = 'sim';
               document.myform.action = 'index.php?id_bib=<?echo $id_bib?>&indice=<?echo $indice?>&inc=gauss3.php';
               document.myform.submit();
            }

        </script>

        <? getSystems($xml_file); ?>
        <? $dim = getDim($indice); ?>
        <? $desc = getDesc($indice); ?>
        <? $com = getCom($indice); ?>
        <? $ref = getRef($indice); ?>
        <? $A = getMatrix($indice); ?>

        <? verificaBib($xml_file); ?>
        <p align="left"><font face="Arial"><b><? echo XML_EXIBE_SELA_MSG02; ?> </b><? echo $dim ?></font>
        <input type="hidden" name=dim value="<? echo $dim ?>">
        <p>
        <? if (!strlen($desc) == 0) { ?>
              <p align="left"><font face="Arial"><b><? echo XML_EXIBE_SELA_MSG03; ?> </b><? echo htmlentities(utf8_decode($desc)) ?></font>
        <? } ?>
        <p>
		<p align="left"><font face="Arial"><b><? echo XML_EXIBE_SELA_MSG04; ?></b></font>
		<p>
		<table border="0">
		<? for ($i=0; $i<$dim; $i++) {	?>
            <tr>
	   	<?	for ($j=0; $j<$dim; $j++) {
	            $aux=$j+1;  ?>
			    <td align=right valign=top> <? echo $A[$i][$j] ?> </td>
			    <input type="hidden" name="A[<? echo $i ?>][<? echo $j ?>]" value="<? echo $A[$i][$j] ?>">
			    <td align=right><font face="Arial">x<sub><? echo ("$aux") ?></sub></font></td>
  	            <?  if ($j<($dim-1)) { ?>
		    		<td align=center width="20"> <? echo (" + "); ?> </td>
				<? }
            } /* end for j */?>
	  		<td align=center width="20"> <? echo (" = ");  ?></td>
	   		<td align=right valign=top><? echo $A[$i][$j] ?></td>
	   		<input type="hidden" name="A[<? echo $i ?>][<? echo $j ?>]" value="<? echo $A[$i][$j] ?>">
			</tr>
		<? } //end for i ?>
        </table>
        <p>
        <? if (!$com == null) { ?>
              <p align="left"><font face="Arial"><b><? echo XML_EXIBE_MSG08;?></b><? echo htmlentities(utf8_decode($com)) ?></font>
        <? } ?>
        <p>
        <? if (!$ref == null) { ?>
              <p align="left"><font face="Arial"><b><? echo XML_EXIBE_MSG09; ?> </b><? echo htmlentities(utf8_decode($ref)) ?></font>
        <? } ?>
        <p>


        <input type="hidden" name="xml_file" value="<? echo $xml_file ?>">
        <input type="hidden" name="Calcular" >
	<input type="hidden" name="navegacao" value="sim">
        <input class="button" type="button" value=<? echo XML_EXIBE_MSG010; ?> onClick="sendToCalculus()"><p>
        </form>

	<?
	echo "<form name=\"exemplos\" enctype=\"multipart/form-data\" method=\"post\">";
	echo "<script language=\"javascript\" type=\"text/javascript\">\n";
	echo "function criarLinks(value) {\n";
	echo "document.exemplos.indice.value = value;\n";
	echo "document.exemplos.action = 'index.php?inc=exibe_prob_sela_gauss3_xml.php'\n";
	echo "document.exemplos.submit();\n";
	echo "}\n";
	echo "</script>";
	echo "<input type=\"hidden\" name=\"id_bib\" value=\"".$id_bib."\">";
	echo "<input type=\"hidden\" name=\"xml_file\" value=\"".$xml_file."\">";
	echo "<input type=\"hidden\" name=\"indice\">";
	echo "<br><br>Outros exemplos<br>";
	//$objeto  = domxml_open_file($xml_file);
	//$raiz = $objeto->document_element();
    $objeto = new DOMDocument();
    $objeto->load($xml_file);
	$filho = $objeto->getelementsbytagname("lin_systems");
	if ($filho->length > 0)
	{
		$temp = $filho->item(0)->getelementsbytagname("system");
		$j = 0;
		for($i = 0; $i < $temp->length; $i++)
		{
			$method = $temp->item($i)->getelementsbytagname("method");
			$conteudo = $method->item(0)->nodeValue;
			$dim = $temp->item($i)->getelementsbytagname("dim");
			$dim = $dim->item(0)->nodeValue;
			if ($conteudo == 'direct')
			{
				if ($j != 0) echo " | ";
				if ($j == $indice) echo "<b>";
				echo "<a href=\"javascript:criarLinks($j)\" title=\"Dimens&atilde;o $dim\"><u>".($j+1)."</u></a>";
				if ($j == $indice) echo "</b>";
				$j++;
			}
		}
	}
	echo "<br>";
	?>

<? } ?>
